package com.qfjy.controller;

import com.qfjy.common.utils.result.ResultCode;
import com.qfjy.common.utils.result.ResultJson;
import com.qfjy.entity.po.Demo;
import com.qfjy.service.DemoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @ClassName DemoController
 * @Description TODO
 * @Author guoweixin
 * @Date 2023/2/24
 * @Version 1.0
 */
@Controller
@Slf4j
@RequestMapping("demo")
@Api(tags = {"案例模块"})
public class DemoController {

    @Autowired
    private DemoService demoService;


    @GetMapping("select")
    @ResponseBody
    @ApiOperation(value = "根据demo查找信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "主键",defaultValue ="1")
    })
    public Object selectDemoById(@RequestParam("id") final Integer id){
        Demo demo=demoService.selectByPrimaryKey(id);

        if(demo==null){
            return new ResultJson<>(null, ResultCode.NOT_DATA);
        }

        return new ResultJson<>(demo,ResultCode.SUCCESS);
    }
}
